********************************************************************************
* Do file for online appendices (last updated on Feb. 27, 2023)
*
* TITLE  : Does Peacekeeping by Civilians Work? Reducing Armed Violence without Armed Force
* JOURNAL: Japanese Journal of Political Science
* AUTHOR : ASANO, Rui
*
* All data analyses in this file were carried out using Stata/MP 15.1 for Mac (64-bit Intel).
********************************************************************************

/*Setting*/
	cls
	version 15.1
	clear all
	*set more off, perm
	*set matsize 11000, perm
	*set scheme s1mono, perm
	*ssc install estout
	cd "[set your directory]"
	/*Please make a folder named "Figures" in the "Data" folder in case you save figures created in this do file.*/





********************************************************************************
/*Data collection*/

/*1. The Basics of UN Peace Operations (BAPO) dataset*/
	use "Data/02. Peacekeeping/UNPO1_mission_list.dta", clear
	tab MissionType, m /*UNOMSA and UNAMIS are not PKOs nor SPMs.*/

/*Figure A1*/
	*sum StartYear
	*tab MissionAbbrev if Ongoing == 0 & EndYear == . /*OSES and UNSMA*/
	drop if MissionAbbrev == "OSES" | MissionAbbrev == "UNSMA"

	gen t = .
	gen num_pkost = .
	gen num_spmst = .
	gen pkost_all = .
	gen spmst_all = .
	gen pkoen_all = .
	gen spmen_all = .
	local i = 1
	foreach num of numlist 1948/2019 {
		replace t = `num' in `i'

		count if MissionType == "PKO" & StartYear == `num'
		replace num_pkost = r(N) if t == `num'
		count if MissionType == "SPM" & StartYear == `num'
		replace num_spmst = r(N) if t == `num'

		count if MissionType == "PKO" & StartYear <= `num'
		replace pkost_all = r(N) if t == `num'
		count if MissionType == "SPM" & StartYear <= `num'
		replace spmst_all = r(N) if t == `num'

		count if MissionType == "PKO" & EndYear <= `num'
		replace pkoen_all = r(N) if t == `num'
		count if MissionType == "SPM" & EndYear <= `num'
		replace spmen_all = r(N) if t == `num'

		local i = `i' + 1
	}

	gen num_pko = pkost_all - pkoen_all
	gen num_spm = spmst_all - spmen_all
	gen num_unpost = num_pkost + num_spmst
	twoway ///
		 bar num_spmst            t, fc(blue%50) lc(black) lw(vvthin) || ///
		rbar num_unpost num_spmst t, fc( red%50) lc(black) lw(vvthin) || ///
		line num_pko t, lc(black) lp(dash) || line num_spm t, lc(black) lp(dot) ///
		xlabel(1950(20)2020) ylabel(0(5)16, angle(0) grid) xtitle("") plotregion(lc(none))              ///
		legend(order(2 "# of PKO starts" 1 "# of SPM starts" 3 "# of active PKOs" 4 "# of active SPMs") ///
		       region(lc(none) fc(none)) ring(0) position(11) row(4))
	*graph export "Data/Figures/FigA1_UN_peace_operations_trends.pdf", as(pdf) replace




/*2. UN Peacekeeping Operations Financial Resources (PKOF) dataset*/
	use "Data/02. Peacekeeping/UNPO6_financial_resources_base.dta", clear /*Note: Please check Dataset_monthly.dta or UNPO6_..._conflict-month.dta regarding the description of the variables on UN PKO financial resources.*/
	drop if MissionAbbrev == "UNOMSA" | MissionAbbrev == "UNAMIS" /*These two are not PKOs nor SPMs.*/


/*Figure A3*/
	*br if Mission2Abbrev != "" | Mission3Abbrev != "" /*Some obs represent multiple missions.*/
	graph hbar (count), ///
		over(MissionAbbrev, sort(1) descending label(labsize(vsmall))) ///
		bar(1, lc(black) fc(black)) ytitle("# of budgetary periods", size(small)) ///
		ylabel(,labsize(small) glw(vthin)) plotregion(lc(none)) xsize(1) ysize(1.4)
	*graph export "Data/Figures/FigA3_Missions_in_the_PKOF.pdf", as(pdf) replace


/*Figure A4*/
	gen location = CountryName
	replace location = TerritoryName if TerritoryName != ""
	replace location = "CAR, Chad"       if MissionAbbrev == "MINURCAT"
	replace location = "Croatia"         if MissionAbbrev == "UNTAES"   | MissionAbbrev == "UNPSG" /*Eastern Slavonia, Baranja, and Western Sirmium*/
	replace location = "Central America" if MissionAbbrev == "ONUCA"
	replace location = "Yugoslavia"      if MissionAbbrev == "UNPROFOR"
	replace location = "CAR (-2000)"     if MissionAbbrev == "MINURCA"
	replace location = "CAR (2014-)"     if MissionAbbrev == "MINUSCA"
	replace location = "Haiti (-2000)"   if MissionAbbrev == "UNMIH"    | MissionAbbrev == "UNSMIH"    | MissionAbbrev == "MIPONUH"
	replace location = "Haiti (2004-)"   if MissionAbbrev == "MINUSTAH" | MissionAbbrev == "MINUJUSTH"
	replace location = "Liberia (-1997)" if MissionAbbrev == "UNOMIL"
	replace location = "Liberia (2003-)" if MissionAbbrev == "UNMIL"
	replace location = "Timor-Leste (-2005)" if MissionAbbrev == "UNMISET"  | MissionAbbrev == "UNTAET"
	replace location = "Timor-Leste (2006-)" if MissionAbbrev == "UNMIT"
	replace location = "DRC"       if location == "Democratic Republic of the Congo"
	replace location = "Macedonia" if location == "The former Yugoslav Republic of Macedonia" /*Now, North Macedonia*/

	sort location PeriodFrom
	by location: gen t = _n
	sort t PeriodFrom location
	by t: gen id = _n if t == 1
	sort location PeriodFrom
	by location: replace id = id[_n-1] if id == .
	sort id PeriodFrom
	*list id location PeriodFrom PeriodTo if t == 1
	label define id 1 "Iran, Iraq" 2 "Angola" 3 "Lebanon" 4 "Namibia" 5 "Central America" 6 "Golan" 7 "Iraq, Kuwait" 8 "Western Sahara" 9 "El Salvador" 10 "Cambodia"                     ///
					11 "Yugoslavia" 12 "Somalia" 13 "Mozambique" 14 "Cyprus" 15 "Rwanda" 16 "Georgia" 17 "Liberia (-1997)" 18 "Haiti (-2000)" 19 "Tajikistan" 20 "Bosnia and Herzegovina" ///
					21 "Croatia" 22 "Guatemala" 23 "Macedonia" 24 "CAR (-2000)" 25 "Sierra Leone" 26 "Kosovo" 27 "DRC" 28 "Timor-Leste (-2005)" 29 "Eritrea, Ethiopia" 30 "Côte d'Ivoire" ///
					31 "Liberia (2003-)" 32 "Burundi" 33 "Haiti (2004-)" 34 "Sudan" 35 "Timor-Leste (2006-)" 36 "CAR, Chad" 37 "Darfur" 38 "Abyei" 39 "South Sudan" 40 "Syrian Arab Republic" 41 "Mali" 42 "CAR (2014-)"
	label values id id

	*br if PeriodTo != PeriodFrom[_n+1] - 1 & location == location[_n+1]
	gen overlap = 0
	replace overlap = 1 if PeriodTo != PeriodFrom[_n+1] - 1 & location == location[_n+1]

	twoway ///
		rcap PeriodFrom PeriodTo id if overlap == 0, lc(black) lw(vthin) horizontal || ///
		rcap PeriodFrom PeriodTo id if overlap == 1, lc(red)   lw(vthin) horizontal    ///
		ylabel(1(1)42, angle(0) notick grid valuelabel labsize(vsmall) glw(vthin))     ///
		xlabel(,format(%tdCCYY) labsize(small)) yscale(reverse noline)                 ///
		xtitle("") ytitle("") legend(order(2 "overlap with the next budgetary period") region(lc(none) fc(none)) ///
		ring(0) position(7) symxsize(2) symysize(2) size(vsmall) keygap(1)) plotregion(lc(none)) xsize(1) ysize(1.4)
	*graph export "Data/Figures/FigA4_Budgetary_periods_by_location.pdf", as(pdf) replace
	*tab PeriodDays Session


/*Figure A5*/
	gen GrossVar_pct = GrossVar / GrossBdg
	graph box GrossVar_pct, ///
		over(Session) ylabel(,angle(0)) m(1, msize(vsmall) mc(black)) box(1, lc(black) fc(black)) ///
		ytitle("Variance to gross total expenditures (proportion)") b1title("UN General Assembly session #", size(medsmall)) ///
		plotregion(lc(none)) xsize(2) ysize(1)
	*graph export "Data/Figures/FigA5_Variance_by_UNGA_session.pdf", as(pdf) replace




/*3. UN Peacekeeping Operations Personnel (PKOP) dataset*/
	use "Data/02. Peacekeeping/UNPO7_personnel_base.dta", clear /*Note: Please check Dataset_monthly.dta or UNPO7_..._conflict-month.dta regarding the description of the variables on UN PKO personnel.*/

/*Figure A6*/
	*br if Mission2Abbrev != "" | Mission3Abbrev != "" /*some obs represent multiple missions.*/
	gen missing = 0
	replace missing = 1 if Military == . | Military2 == . | Police       == . | Civilian == . | Civilian2 == . | ///
						   Milob    == . | Milcon    == . | Officerstaff == . | Civintl  == . | Civnat    == . | ///
						   UNV      == . | OAUob     == . | Officernat   == .
	*tab year missing /*non-missing values only after 1989; a number of missing values in 2001-2005*/

	tab missing, gen(missing)
	graph hbar (sum) missing1 missing2, ///
		stack over(MissionAbbrev, sort(1) descending label(labsize(vsmall)))             ///
		bar(1, fc(red%50) lc(black) lw(vvthin)) bar(2, fc(blue%50) lc(black) lw(vvthin)) ///
		ytitle("# of months", size(small)) ylabel(,labsize(small) glw(vthin))            ///
		legend(order(1 "Non-missing" 2 "Missing") region(lc(none) fc(none))              ///
		ring(0) position(5) symxsize(2) symysize(2) size(vsmall) keygap(1) row(2))       ///
		plotregion(lc(none)) xsize(1) ysize(1.4)
	*graph export "Data/Figures/FigA6_Missions_in_the_PKOP.pdf", as(pdf) replace


/*Figure A7*/
	/*Original data (PKOP)*/
	use "Data/02. Peacekeeping/UNPO7_personnel_base.dta", clear
	tab year month if Civilian != . & Civilian != 0     /*Feb. 1989-Sep. 2019 (nonmissing values)*/
	tab MissionAbbrev if Civilian != . & Civilian != 0
	return list                                         /*54*/
	tab Mission2Abbrev if Civilian != . & Civilian != 0 /*+2: UNCRO, UNMOP*/
	tab Mission3Abbrev if Civilian != . & Civilian != 0 /*+0 -> 54 + 2 = 56 missions*/
	tab location if Civilian != . & Civilian != 0, m
	return list                                         /*Abyei, Darfur, Uganda-Rwanda*2 -> 40 - 4 = 36 countries*/
	count if Civilian != . & Civilian != 0              /*3,917 data points*/

	keep MissionAbbrev year month ym location Civilian Civilian2 Civintl-Officernat
	keep if location == "Angola"        | location == "Burundi"      | location == "Central African Republic" | ///
			location == "Côte d'Ivoire" | location == "Democratic Republic of the Congo"                      | ///
			location == "Liberia"       | location == "Mali"         | location == "Mozambique"               | ///
			location == "Rwanda"        | location == "Sierra Leone" | location == "Somalia"                  | ///
			location == "South Sudan"   | location == "Sudan" | location == "Darfur" | location == "Abyei"
	*list if location == location[_n-1] & ym == ym[_n-1]
	drop if (MissionAbbrev == "UNAVEM II" & (ym == 376 | ym == 421)) | ///
			(MissionAbbrev == "MINUCI"    & (ym == 530 | ym == 531)) | ///
			(MissionAbbrev == "UNOMSIL"   & (ym == 478 | ym == 479)) | ///
			(MissionAbbrev == "UNOSOM I"  & ym == 398)
	rename location country
	replace country = "Cote d'Ivoire" if country == "Côte d'Ivoire"
	replace country = "Sudan" if country == "Darfur" | country == "Abyei"
	sort country ym MissionAbbrev
	foreach var of varlist Civilian-Officernat {
		by country ym: egen missing = max(missing(`var'))
		by country ym: egen sum_`var' = sum(`var') if missing == 0
		replace `var' = sum_`var'
		drop missing sum_`var'
	}
	duplicates drop country ym, force
	drop MissionAbbrev
	*save "Data/02. Peacekeeping/UNPO9_personnel_base_compare.dta", replace


	/*Blair data*/
	use "RawData/05. Replication files/Blair 2021 APSR/data.dta", clear /*Download "data.tab" from <https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/NRRVJ3>.*/
	tab year if iactual_civilian_totalK_2l != . & iactual_civilian_totalK_2l != 0 /*1995-2016 -> 1993-2014 because of 2 lags*/
	list country year if iactual_civilian_totalK_2l != . & iactual_civilian_totalK_2l != 0
	/*SPM ( 8): UNOGBIS, UNOL, UNIOSIL, BONUCA, UNOB, BINUB, UNPOS, UNSOM
	  PKO (18): MINUSMA, MINUCI, UNOCI, UNOMIL, UNMIL, UNAMSIL, MONUC, MONUSCO, ONUB, UNAMIR, UNOSOM I, UNOSOM II, MONUA, ONUMOZ, UNMIS, UNAMID, UNISFA, UNMISS*/
	tab country if iactual_civilian_totalK_2l != . & iactual_civilian_totalK_2l != 0
	return list /*14 countries*/
	count if iactual_civilian_totalK_2l != . & iactual_civilian_totalK_2l != 0

	keep year gwnoloc country iactual_*_totalK_2l
	foreach x in iactual_civilian_totalK iactual_hiciv_totalK iactual_lowciv_totalK {
		gen `x' = (f2.`x'_2l) * 1000
	}
	*tab country if iactual_civilian_totalK != . & iactual_civilian_totalK != 0
	keep if country == "Angola"        | country == "Burundi" | country == "Central African Republic" | ///
			country == "Cote d'Ivoire" | country == "Democratic Republic of the Congo"                | ///
			country == "Guinea-Bissau" | country == "Liberia"     | country == "Mali"                 | ///
			country == "Mozambique"    | country == "Rwanda"      | country == "Sierra Leone"         | ///
			country == "Somalia"       | country == "South Sudan" | country == "Sudan"
	gen ym = ym(year,1)
	merge 1:1 country year ym using "Data/02. Peacekeeping/UNPO9_personnel_base_compare.dta"
	sort country ym

	twoway ///
		scatter iactual_civilian_totalK ym if iactual_civilian_totalK != 0, msize(small) mfc(blue%50) mlc(black) mlw(thin) || ///
		line    Civilian                ym if Civilian                != 0, lc(red%50) lw(thick) ///
		by(country, note("")) cmissing(n) legend(order(1 "Blair data (regarded in January)" 2 "Original data") region(lc(none)) size(small)) ///
		xlabel(,format(%tmCCYY) grid) ylabel(0(2500)10000, format(%9.0gc) angle(0) grid)  ///
		xtitle("") ytitle("# of civilian peacekeepers", size(small)) xsize(1.75) ysize(1)
	*graph export "Data/Figures/FigA7_Comparison_with_Blair_data.pdf", as(pdf) replace





********************************************************************************
/*Research design*/
	use "Data/Dataset_monthly.dta", clear

/*Table B1*/
	/*Deployed before the war started*/
	tab year month if location == "Central African Republic" /*after May  2001*/
	tab year month if location == "Macedonia, FYR"           /*after Jan. 2000*/

	/*Deployed where no conflicts occurred*/
	tab year month if location == "East Timor"               /*no conflicts after independence*/





********************************************************************************
/*Robustness checks and additional analyses*/

/*1. Other time unit of analysis (using annual data)*/
	use "Data/Dataset_monthly.dta", clear
	codebook bd_best_ged bd_govt_ged bd_rebel_ged
	scatter bd_best_ged l.bd_best_ged
	use "Data/Dataset_annual.dta", clear
	codebook bd_best_ged bd_govt_ged bd_rebel_ged  /*Annual data show fewer percentages of 0s and larger variance.*/
	scatter bd_best_ged l.bd_best_ged              /*Annual data show a stronger correlation between BRDs at t and t-1.*/

	global pkexps   = "l.ln_srf_civilianexp l.ln_srf_militaryexp l.ln_srf_policeexp"
	global controls = "pa bd_total_osv_govt_binary bd_total_osv_rebel_binary bd_total_nsv_binary ln_oda ln_milper ln_gdp ln_pop v2x_polyarchy l.spm ropko stpko"
	/*ropko and stpko can be lagged, but I use the same specification as the monthly analysis.*/

	/*(1) DV = all BRDs*/
	xtreg bd_best_ged $pkexps $controls i.year c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local Year_FEs "YES"
	estadd local War_FEsT "YES"
	est sto m1_year

	/*(2) DV = BRDs on the government side*/
	xtreg bd_govt_ged $pkexps $controls i.year c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local Year_FEs "YES"
	estadd local War_FEsT "YES"
	est sto m2_year

	/*(3) DV = BRDs on the rebel side*/
	xtreg bd_rebel_ged $pkexps $controls i.year c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local Year_FEs "YES"
	estadd local War_FEsT "YES"
	est sto m3_year

	esttab m1_year m2_year m3_year, /*tex*/ ///
		nogap compress unstack noomitted drop(*.year *.conflict_id#c.time _cons) b(3) se(3) ///
		stat(War_FEs Year_FEs War_FEsT N r2_w, label("War FEs" "Year FEs" "War FEs * t" "N" "R-squared (within)") ///
		fmt(%3s %3s %3s %9.0gc %12.3fc)) star(+ 0.10 * 0.05 ** 0.01 *** 0.001)              ///
		title("FE OLS using annual data")                                                   ///
		/*numbers("Model C1-")*/ varwidth(33) modelwidth(10) mlabels("Total" "Government" "Rebel") ///
		coeflabels(L.ln_srf_civilianexp "Civilian Expenditures\(_{t-1}\)" L.ln_srf_militaryexp "Military Expenditures\(_{t-1}\)" L.ln_srf_policeexp "Police Expenditures\(_{t-1}\)" ///
				   pa "Peace Agreement" bd_total_osv_govt_binary "Government OSV"                 ///
				   bd_total_osv_rebel_binary "Rebel OSV" bd_total_nsv_binary "Non-State Violence" ///
				   ln_oda "log(ODA)" ln_milper "log(Army Size)" ln_gdp "log(GDP)" ln_pop "log(Population)" ///
				   v2x_polyarchy "Democracy" L.spm "SPM\(_{t-1}\)" ropko "Regional PKO" stpko "State PKO") ///
		note("Robust standard errors clustered at conflict in parentheses.")




/*2. Other measurements of peacekeeping variables*/
	use "Data/Dataset_monthly.dta", clear

	label variable ln_srf_civilianexp "Civilian expenditures/ logarithmic area"
	label variable ln_srf_civilian    "Civilian peacekeepers/ logarithmic area"
	label variable civilianexp        "Civilian expenditures; unadjusted by area"

	sum ln_srf_civilianexp ln_srf_civilian civilianexp
	graph matrix ///
		ln_srf_civilianexp ln_srf_civilian civilianexp if civilianexp > 0 | civilian > 0, ///
		half diagopt(size(medsmall) fc(pink%50)) ms(p) mc(black) ///
		xlabel(0(150)600,  grid format(%12.0fc) labsize(small) axis(2)) ///
		ylabel(0(150)600,  grid format(%12.0fc) labsize(small) axis(2)) ///
		xlabel(0(30)120,   grid format(%12.0fc) labsize(small) axis(1)) ///
		ylabel(0(400)1600, grid format(%12.0fc) labsize(small) axis(3)) ///
		xsize(1) ysize(1)
	*graph export "Data/Figures/FigC1_Correlations_between_different_measurements.pdf", as(pdf) replace

	*global pkexps        = "l.ln_srf_civilianexp l.ln_srf_militaryexp l.ln_srf_policeexp"
	global pks           = "l.ln_srf_civilian l.ln_srf_military2 l.ln_srf_police"
	global pkexps_nonsrf = "l.civilianexp     l.militaryexp     l.policeexp"
	global controls      = "pa bd_total_osv_govt_binary bd_total_osv_rebel_binary bd_total_nsv_binary ln_oda ln_milper ln_gdp ln_pop v2x_polyarchy l.spm ropko stpko"


	/*# of peacekeepers:
	  civilian  = excluding OAU observers and national officers;
	  military2 = including staff officers*/
	/*(1) DV = all BRDs*/
	xtreg bd_best_ged $pks $controls i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m1_pks

	/*(2) DV = BRDs on the government side*/
	xtreg bd_govt_ged $pks $controls i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m2_pks

	/*(3) DV = BRDs on the rebel side*/
	xtreg bd_rebel_ged $pks $controls i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m3_pks

	esttab m1_pks m2_pks m3_pks, /*tex*/ ///
		nogap compress unstack noomitted drop(*.ym *.conflict_id#c.time _cons) b(3) se(3) ///
		stat(War_FEs YM_FEs War_FEsT N r2_w, label("War FEs" "Year-month FEs" "War FEs * t" "N" "R-squared (within)") ///
		fmt(%3s %3s %3s %9.0gc %12.3fc)) star(+ 0.10 * 0.05 ** 0.01 *** 0.001)            ///
		title("FE OLS using the number of peacekeepers")                                  ///
		/*numbers("Model C2-")*/ varwidth(33) modelwidth(10) mlabels("Total" "Government" "Rebel") ///
		coeflabels(L.ln_srf_civilian "Civilian Peacekeepers\(_{t-1}\)" L.ln_srf_military2 "Military Peacekeepers\(_{t-1}\)" L.ln_srf_police "Police Peacekeepers\(_{t-1}\)" ///
				   pa "Peace Agreement" bd_total_osv_govt_binary "Government OSV"                 ///
				   bd_total_osv_rebel_binary "Rebel OSV" bd_total_nsv_binary "Non-State Violence" ///
				   ln_oda "log(ODA)" ln_milper "log(Army Size)" ln_gdp "log(GDP)" ln_pop "log(Population)" ///
				   v2x_polyarchy "Democracy" L.spm "SPM\(_{t-1}\)" ropko "Regional PKO" stpko "State PKO") ///
		note("Robust standard errors clustered at conflict in parentheses.")


	/*Expenditures not per (any functions of) surface area*/
	/*(1) DV = all BRDs*/
	xtreg bd_best_ged $pkexps_nonsrf $controls i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m1_nonsrf

	/*(2) DV = BRDs on the government side*/
	xtreg bd_govt_ged $pkexps_nonsrf $controls i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m2_nonsrf

	/*(3) DV = BRDs on the rebel side*/
	xtreg bd_rebel_ged $pkexps_nonsrf $controls i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m3_nonsrf

	esttab m1_nonsrf m2_nonsrf m3_nonsrf, /*tex*/ ///
		nogap compress unstack noomitted drop(*.ym *.conflict_id#c.time _cons) b(3) se(3) ///
		stat(War_FEs YM_FEs War_FEsT N r2_w, label("War FEs" "Year-month FEs" "War FEs * t" "N" "R-squared (within)") ///
		fmt(%3s %3s %3s %9.0gc %12.3fc)) star(+ 0.10 * 0.05 ** 0.01 *** 0.001)            ///
		title("FE OLS using PKO expenditures unadjusted by area")                         ///
		/*numbers("Model C3-")*/ varwidth(55) modelwidth(10) mlabels("Total" "Government" "Rebel") ///
		coeflabels(L.civilianexp "Civilian Expenditures\(_{t-1}\) (unadjusted by area)" L.militaryexp "Military Expenditures\(_{t-1}\) (unadjusted by area)" L.policeexp "Police Expenditures\(_{t-1}\) (unadjusted by area)" ///
				   pa "Peace Agreement" bd_total_osv_govt_binary "Government OSV"                 ///
				   bd_total_osv_rebel_binary "Rebel OSV" bd_total_nsv_binary "Non-State Violence" ///
				   ln_oda "log(ODA)" ln_milper "log(Army Size)" ln_gdp "log(GDP)" ln_pop "log(Population)" ///
				   v2x_polyarchy "Democracy" L.spm "SPM\(_{t-1}\)" ropko "Regional PKO" stpko "State PKO") ///
		note("Robust standard errors clustered at conflict in parentheses.")




/*3. Other combinations of control variables*/
	use "Data/Dataset_monthly.dta", clear

	global pkexps              = "l.ln_srf_civilianexp l.ln_srf_militaryexp l.ln_srf_policeexp"
	global controls            = "pa bd_total_osv_govt_binary bd_total_osv_rebel_binary bd_total_nsv_binary ln_oda ln_milper ln_gdp ln_pop v2x_polyarchy l.spm ropko stpko"
	global controls_nomissing  = "pa bd_total_osv_govt_binary bd_total_osv_rebel_binary bd_total_nsv_binary ln_pop v2x_polyarchy l.spm ropko stpko"
	global controls_nomediator = "bd_total_nsv_binary ln_oda ln_milper ln_pop l.spm ropko stpko"

	/*Excluding military and police expenditures
	  -> Considering multicollinearity among different components of UN peacekeeping*/
	pwcorr $pkexps, sig
	pwcorr $pkexps if l.ln_srf_civilianexp != 0 | l.ln_srf_militaryexp != 0 | l.ln_srf_policeexp != 0, sig

	/*(1) DV = all BRDs*/
	xtreg bd_best_ged l.ln_srf_civilianexp $controls i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m1_nomilpol

	/*(2) DV = BRDs on the government side*/
	xtreg bd_govt_ged l.ln_srf_civilianexp $controls i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m2_nomilpol

	/*(3) DV = BRDs on the rebel side*/
	xtreg bd_rebel_ged l.ln_srf_civilianexp $controls i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m3_nomilpol

	esttab m1_nomilpol m2_nomilpol m3_nomilpol, tex ///
		nogap compress unstack noomitted drop(*.ym *.conflict_id#c.time _cons) b(3) se(3) ///
		stat(War_FEs YM_FEs War_FEsT N r2_w, label("War FEs" "Year-month FEs" "War FEs * t" "N" "R-squared (within)") ///
		fmt(%3s %3s %3s %9.0gc %12.3fc)) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
		title("FE OLS without military and police expenditures")               ///
		/*numbers("Model C4-")*/ varwidth(33) modelwidth(10) mlabels("Total" "Government" "Rebel") ///
		coeflabels(L.ln_srf_civilianexp "Civilian Expenditures\(_{t-1}\)" L.ln_srf_militaryexp "Military Expenditures\(_{t-1}\)" L.ln_srf_policeexp "Police Expenditures\(_{t-1}\)" ///
				   pa "Peace Agreement" bd_total_osv_govt_binary "Government OSV"                  ///
				   bd_total_osv_rebel_binary "Rebel OSV" bd_total_nsv_binary "Non-State Violence"  ///
				   ln_oda "log(ODA)" ln_milper "log(Army Size)" ln_gdp "log(GDP)" ln_pop "log(Population)" ///
				   v2x_polyarchy "Democracy" L.spm "SPM\(_{t-1}\)" ropko "Regional PKO" stpko "State PKO") ///
		note("Robust standard errors clustered at conflict in parentheses.")


	/*Excluding control variables with many missing values
	  = excl. ODA, army size, and GDP*/
	count
	count if ln_oda    == .
	dis 7766 / 56908        /*13.65%*/
	*count if    oda     < 0
	*dis 1198 / 7766         /*15.43%*/
	count if ln_milper == .
	dis 4215 / 56908        /* 7.41%*/
	count if ln_gdp    == .
	dis 3189 / 56908        /* 5.60%*/

	gen withexp = 0 if ln_srf_militaryexp != . & ln_srf_policeexp != . & ln_srf_civilianexp != .
	recode withexp (0=1) if ln_srf_militaryexp != 0 | ln_srf_policeexp != 0 | ln_srf_civilianexp != 0
	count if withexp == 1
	count if withexp == 1 & ln_oda    == .
	dis 233 / 3515                         /* 6.63%*/
	count if withexp == 1 & ln_milper == .
	dis 489 / 3515                         /*13.91%*/
	count if withexp == 1 & ln_gdp    == .
	dis 236 / 3515                         /* 6.71%*/

	/*(1) DV = all BRDs*/
	xtreg bd_best_ged $pkexps $controls_nomissing i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m1_nomissing

	/*(2) DV = BRDs on the government side*/
	xtreg bd_govt_ged $pkexps $controls_nomissing i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m2_nomissing

	/*(3) DV = BRDss on the rebel side*/
	xtreg bd_rebel_ged $pkexps $controls_nomissing i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m3_nomissing

	esttab m1_nomissing m2_nomissing m3_nomissing, /*tex*/ ///
		nogap compress unstack noomitted drop(*.ym *.conflict_id#c.time _cons) b(3) se(3) ///
		stat(War_FEs YM_FEs War_FEsT N r2_w, label("War FEs" "Year-month FEs" "War FEs * t" "N" "R-squared (within)") ///
		fmt(%3s %3s %3s %9.0gc %12.3fc)) star(+ 0.10 * 0.05 ** 0.01 *** 0.001)            ///
		title("FE OLS excluding control variables with many missing values")              ///
		/*numbers("Model C5-")*/ varwidth(33) modelwidth(10) mlabels("Total" "Government" "Rebel") ///
		coeflabels(L.ln_srf_civilianexp "Civilian Expenditures\(_{t-1}\)" L.ln_srf_militaryexp "Military Expenditures\(_{t-1}\)" L.ln_srf_policeexp "Police Expenditures\(_{t-1}\)" ///
				   pa "Peace Agreement" bd_total_osv_govt_binary "Government OSV"                 ///
				   bd_total_osv_rebel_binary "Rebel OSV" bd_total_nsv_binary "Non-State Violence" ///
				   ln_pop "log(Population)" v2x_polyarchy "Democracy" L.spm "SPM\(_{t-1}\)" ropko "Regional PKO" stpko "State PKO") ///
		note("Robust standard errors clustered at conflict in parentheses.")


	/*Excluding potential mediator variables
	  =  excl. peace agreement, government/rebel OSV, GDP, and democracy
	  -> Note: I do not use values at a conflict's beginning, which are constant across time, because I employ FE models*/
	/*(1) DV = all BRDs*/
	xtreg bd_best_ged $pkexps $controls_nomediator i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m1_nomediator

	/*(2) DV = BRDs on the government side*/
	xtreg bd_govt_ged $pkexps $controls_nomediator i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m2_nomediator

	/*(3) DV = BRDss on the rebel side*/
	xtreg bd_rebel_ged $pkexps $controls_nomediator i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m3_nomediator

	esttab m1_nomediator m2_nomediator m3_nomediator, /*tex*/ ///
		nogap compress unstack noomitted drop(*.ym *.conflict_id#c.time _cons) b(3) se(3) ///
		stat(War_FEs YM_FEs War_FEsT N r2_w, label("War FEs" "Year-month FEs" "War FEs * t" "N" "R-squared (within)") ///
		fmt(%3s %3s %3s %9.0gc %12.3fc)) star(+ 0.10 * 0.05 ** 0.01 *** 0.001)            ///
		title("FE OLS excluding potential mediator variables")                            ///
		/*numbers("Model C6-")*/ varwidth(33) modelwidth(10) mlabels("Total" "Government" "Rebel") ///
		coeflabels(L.ln_srf_civilianexp "Civilian Expenditures\(_{t-1}\)" L.ln_srf_militaryexp "Military Expenditures\(_{t-1}\)" L.ln_srf_policeexp "Police Expenditures\(_{t-1}\)" ///
				   bd_total_nsv_binary "Non-State Violence"  ln_oda "log(ODA)" ln_milper "log(Army Size)" ln_pop "log(Population)" ///
				   L.spm "SPM\(_{t-1}\)" ropko "Regional PKO" stpko "State PKO") ///
		note("Robust standard errors clustered at conflict in parentheses.")




/*4. Other estimation strategies*/
	use "Data/Dataset_monthly.dta", clear
	global pkexps   = "l.ln_srf_civilianexp l.ln_srf_militaryexp l.ln_srf_policeexp"
	global controls = "pa bd_total_osv_govt_binary bd_total_osv_rebel_binary bd_total_nsv_binary ln_oda ln_milper ln_gdp ln_pop v2x_polyarchy l.spm ropko stpko"

	/*Logistic regression models on death occurrence*/
	local i = 1
	foreach var of varlist bd_best_ged bd_govt_ged bd_rebel_ged {
		if `i' == 1 {
			gen `var'_binary = .
			replace `var'_binary = 1 if `var' > 2 & `var' != .
			replace `var'_binary = 0 if `var' <= 2
		}
		if `i' >= 2 {
			gen `var'_binary = .
			replace `var'_binary = 1 if `var' > 1 & `var' != .
			replace `var'_binary = 0 if `var' <= 1
		}
		local i = `i' + 1
	}

	/*(1) DV = all BRDs*/
	clogit bd_best_ged_binary $pkexps $controls, group(conflict_id) cluster(conflict_id) nonest
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "NO"
	estadd local War_FEsT "NO"
	est sto m1_clogit

	/*(2) DV = BRDs on the government side*/
	clogit bd_govt_ged_binary $pkexps $controls, group(conflict_id) cluster(conflict_id) nonest
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "NO"
	estadd local War_FEsT "NO"
	est sto m2_clogit

	/*(3) DV = BRDs on the rebel side*/
	clogit bd_rebel_ged_binary $pkexps $controls, group(conflict_id) cluster(conflict_id) nonest
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "NO"
	estadd local War_FEsT "NO"
	est sto m3_clogit

	esttab m1_clogit m2_clogit m3_clogit, /*tex*/ ///
		nogap compress unstack noomitted b(a3) se(3)                           ///
		stat(War_FEs YM_FEs War_FEsT N r2_p, label("War FEs" "Year-month FEs" "War FEs * t" "N" "Pseudo R-squared") ///
		fmt(%3s %3s %3s %9.0gc %12.3fc)) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
		title("Conditional logistic regression on death occurrence")           ///
		/*numbers("Model C7-")*/ varwidth(33) modelwidth(10) mlabels("Total" "Government" "Rebel") eqlabels(none) ///
		coeflabels(L.ln_srf_civilianexp "Civilian Expenditures\(_{t-1}\)" L.ln_srf_militaryexp "Military Expenditures\(_{t-1}\)" L.ln_srf_policeexp "Police Expenditures\(_{t-1}\)" ///
				   pa "Peace Agreement" bd_total_osv_govt_binary "Government OSV"                 ///
				   bd_total_osv_rebel_binary "Rebel OSV" bd_total_nsv_binary "Non-State Violence" ///
				   ln_oda "log(ODA)" ln_milper "log(Army Size)" ln_gdp "log(GDP)" ln_pop "log(Population)" ///
				   v2x_polyarchy "Democracy" L.spm "SPM\(_{t-1}\)" ropko "Regional PKO" stpko "State PKO") ///
		note("Robust standard errors clustered at conflict in parentheses.")


	/*Zero-inflated negative binomial (ZINB) models*/
	foreach var of varlist ln_srf_civilianexp ln_srf_militaryexp ln_srf_policeexp spm {
		gen l_`var' = l.`var'
	}
	global l_pkexps   = "l_ln_srf_civilianexp l_ln_srf_militaryexp l_ln_srf_policeexp"
	global l_controls = "pa bd_total_osv_govt_binary bd_total_osv_rebel_binary bd_total_nsv_binary ln_oda ln_milper ln_gdp ln_pop v2x_polyarchy l_spm ropko stpko"

	/*(1) DV = all BRDs*/
	zinb bd_best_ged $l_pkexps $l_controls, inflate($l_pkexps $l_controls) cluster(conflict_id)
	estadd local War_FEs  "NO"
	estadd local YM_FEs   "NO"
	estadd local War_FEsT "NO"
	est sto m1_zinb

	/*(2) DV = BRDs on the government side*/
	zinb bd_govt_ged $l_pkexps $l_controls, inflate($l_pkexps $l_controls) cluster(conflict_id)
	estadd local War_FEs  "NO"
	estadd local YM_FEs   "NO"
	estadd local War_FEsT "NO"
	est sto m2_zinb

	/*(3) DV = BRDs on the rebel side*/
	zinb bd_rebel_ged $l_pkexps $l_controls, inflate($l_pkexps $l_controls) cluster(conflict_id)
	estadd local War_FEs  "NO"
	estadd local YM_FEs   "NO"
	estadd local War_FEsT "NO"
	est sto m3_zinb

	esttab m1_zinb m2_zinb m3_zinb, /*tex*/ ///
		nogap compress unstack noomitted drop(lnalpha) b(3) se(3)              ///
		stat(War_FEs YM_FEs War_FEsT N ll, label("War FEs" "Year-month FEs" "War FEs * t" "N" "Log pseudo likelihood") ///
		fmt(%3s %3s %3s %9.0gc %12.3fc)) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
		title("ZINB regression on the number of battle-related deaths")        ///
		/*numbers("Model C8-")*/ varwidth(33) modelwidth(10) mlabels("Total" "Government" "Rebel") eqlabels(none) ///
		coeflabels(l_ln_srf_civilianexp "Civilian Expenditures\(_{t-1}\)" l_ln_srf_militaryexp "Military Expenditures\(_{t-1}\)" l_ln_srf_policeexp "Police Expenditures\(_{t-1}\)" ///
				   pa "Peace Agreement" bd_total_osv_govt_binary "Government OSV"                 ///
				   bd_total_osv_rebel_binary "Rebel OSV" bd_total_nsv_binary "Non-State Violence" ///
				   ln_oda "log(ODA)" ln_milper "log(Army Size)" ln_gdp "log(GDP)" ln_pop "log(Population)" ///
				   v2x_polyarchy "Democracy" l_spm "SPM\(_{t-1}\)" ropko "Regional PKO" stpko "State PKO" _cons "Constant") ///
		note("Robust standard errors clustered at conflict in parentheses.")




/*5. Other sample selections in terms of PKO expenditures*/
	use "Data/Dataset_monthly.dta", clear
	global pkexps   = "l.ln_srf_civilianexp l.ln_srf_militaryexp l.ln_srf_policeexp"
	global controls = "pa bd_total_osv_govt_binary bd_total_osv_rebel_binary bd_total_nsv_binary ln_oda ln_milper ln_gdp ln_pop v2x_polyarchy l.spm ropko stpko"

	/*Only PKO Cases*/
	gen withexp = 0 if ln_srf_militaryexp != . & ln_srf_policeexp != . & ln_srf_civilianexp != .
	recode withexp (0=1) if ln_srf_militaryexp != 0 | ln_srf_policeexp != 0 | ln_srf_civilianexp != 0

	/*(1) DV = all BRDs*/
	xtreg bd_best_ged $pkexps $controls i.ym c.time#i.conflict_id if withexp == 1, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m1_onlypko

	/*(2) DV = BRDs on the government side*/
	xtreg bd_govt_ged $pkexps $controls i.ym c.time#i.conflict_id if withexp == 1, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m2_onlypko

	/*(3) DV = BRDs on the rebel side*/
	xtreg bd_rebel_ged $pkexps $controls i.ym c.time#i.conflict_id if withexp == 1, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m3_onlypko

	esttab m1_onlypko m2_onlypko m3_onlypko, /*tex*/ ///
		nogap compress unstack noomitted drop(*.ym *.conflict_id#c.time _cons) b(3) se(3) ///
		stat(War_FEs YM_FEs War_FEsT N r2_w, label("War FEs" "Year-month FEs" "War FEs * t" "N" "R-squared (within)") ///
		fmt(%3s %3s %3s %9.0gc %12.3fc)) star(+ 0.10 * 0.05 ** 0.01 *** 0.001)            ///
		title("FE OLS using only cases with PKO expenditures")                            ///
		/*numbers("Model C9-")*/ varwidth(33) modelwidth(10) mlabels("Total" "Government" "Rebel") ///
		coeflabels(L.ln_srf_civilianexp "Civilian Expenditures\(_{t-1}\)" L.ln_srf_militaryexp "Military Expenditures\(_{t-1}\)" L.ln_srf_policeexp "Police Expenditures\(_{t-1}\)" ///
				   pa "Peace Agreement" bd_total_osv_govt_binary "Government OSV"                 ///
				   bd_total_osv_rebel_binary "Rebel OSV" bd_total_nsv_binary "Non-State Violence" ///
				   ln_oda "log(ODA)" ln_milper "log(Army Size)" ln_gdp "log(GDP)" ln_pop "log(Population)" ///
				   v2x_polyarchy "Democracy" L.spm "SPM\(_{t-1}\)" ropko "Regional PKO" stpko "State PKO") ///
		note("Robust standard errors clustered at conflict in parentheses.")


	/*Excluding each PKO case*/
	by conflict_id: egen max_withexp = max(withexp)
	gsort -max_withexp conflict_id ym
	egen g = group(conflict_id) if max_withexp == 1
	sort conflict_id ym

	*tab g /*33 conflicts have hosted UN PKOs.*/
	*br conflict_id location territory_name g if g != .
	gen hostnme = ""
	replace hostnme = "Guatemala"                in  1
	replace hostnme = "Lebanon"                  in  2
	replace hostnme = "DRC"                      in  3
	replace hostnme = "Burundi"                  in  4
	replace hostnme = "Chad"                     in  5
	replace hostnme = "Namibia (South Africa)"   in  6
	replace hostnme = "Syria"                    in  7
	replace hostnme = "Cambodia"                 in  8
	replace hostnme = "Sudan"                    in  9
	replace hostnme = "El Salvador"              in 10
	replace hostnme = "Angola"                   in 11
	replace hostnme = "East Timor (Indonesia)"   in 12
	replace hostnme = "Western Sahara (Morocco)" in 13
	replace hostnme = "Mozambique"               in 14
	replace hostnme = "Nicaragua"                in 15
	replace hostnme = "Somalia"                  in 16
	replace hostnme = "Liberia"                  in 17
	replace hostnme = "Azawad (Mali)"            in 18
	replace hostnme = "Rwanda"                   in 19
	replace hostnme = "Haiti"                    in 20
	replace hostnme = "Sierra Leone"             in 21
	replace hostnme = "Serb (BiH)"               in 22
	replace hostnme = "Serb (Croatia)"           in 23
	replace hostnme = "Abkhazia (Georgia)"       in 24
	replace hostnme = "Tajikistan"               in 25
	replace hostnme = "Bihaca Krajina (BiH)"     in 26
	replace hostnme = "Croat (BiH)"              in 27
	replace hostnme = "Kosovo (Yugoslavia)"      in 28
	replace hostnme = "CAR"                      in 29
	replace hostnme = "Côte d'Ivoire"            in 30
	replace hostnme = "Abyei (Sudan)"            in 31
	replace hostnme = "South Sudan"              in 32
	replace hostnme = "Mali"                     in 33

	gen bciv  = .
	gen pciv  = .
	gen llciv = .
	gen ulciv = .

	foreach num of numlist 1/33 {
		xtreg bd_govt_ged $pkexps $controls i.ym c.time#i.conflict_id if g != `num', fe cluster(conflict_id)

		matrix A = r(table)
		replace bciv  = A[1,1] in `num'
		replace pciv  = A[4,1] in `num'
		replace llciv = A[5,1] in `num'
		replace ulciv = A[6,1] in `num'
	}

	xtreg bd_govt_ged $pkexps $controls i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	matrix A = r(table)
	replace bciv  = A[1,1] in 34
	replace pciv  = A[4,1] in 34
	replace llciv = A[5,1] in 34
	replace ulciv = A[6,1] in 34
	replace hostnme = "original" in 34

	sort bciv llciv ulciv hostnme in 1/34
	*br hostnme-ulciv in 1/34 /*Kosovo, Namibia, and Syria are not included in the analysis sample.*/
	foreach var of varlist bciv-ulciv {
		replace `var' = . if hostnme == "Kosovo (Yugoslavia)" | hostnme == "Namibia (South Africa)" | hostnme == "Syria"
	}
	replace hostnme = "" if hostnme == "Kosovo (Yugoslavia)" | hostnme == "Namibia (South Africa)" | hostnme == "Syria"
	label define hostnme  1 "CAR" 2 "Lebanon" 3 "Chad" 4 "Azawad (Mali)" 5 "Sierra Leone" 6 "East Timor (Indonesia)" 7 "Angola" 8 "Western Sahara (Morocco)" 9 "Croat (BiH)" 10 "Mali"   ///
						  11 "Serb (Croatia)" 12 "Tajikistan" 13 "El Salvador" 14 "Serb (BiH)" 15 "Côte d'Ivoire" 16 "Burundi" 17 "South Sudan" 18 "Rwanda" 19 "Somalia" 20 "Mozambique" ///
						  21 "Abyei (Sudan)" 22 "original" 23 "Liberia" 24 "Guatemala" 25 "Nicaragua" 26 "Abkhazia (Georgia)" 27 "Cambodia" 28 "Bihaca Krajina (BiH)" 29 "Haiti" 30 "DRC" 31 "Sudan"
	sort bciv llciv ulciv hostnme in 1/34
	foreach num of numlist 1/31 {
		replace hostnme = "`num'" in `num'
	}
	destring hostnme, replace
	label values hostnme hostnme

	twoway ///
		rbar llciv ulciv hostnme if pciv <  0.05 & hostnme != 22, barwidth(.2) lc(black%0) fc(black%50) || ///
		rbar llciv ulciv hostnme if hostnme == 22, barwidth(.2) lc(black%0) fc(black%75)                || ///
		rbar llciv ulciv hostnme if pciv >= 0.05, barwidth(.2) lc(red%0) fc(red%50)                     || ///
		connected  bciv  hostnme, lc(black) mc(black) m(oh) msize(large) lp(dot) yline(0, lp(dash) lc(black)) ///
		title("") xtitle("Excluded conflict name") ytitle("Coefficient for {it:Civilian Expenditures}") ///
		xlabel(1(1)31, valuelabel angle(90) labsize(small)) ylabel(-3(1)0.45, grid angle(0))            ///
		legend(order(4 "point estimate" 1 "significant at 5%" 3 "not significant") region(lc(none) fc(none)) ///
		symxsize(2) symysize(2) size(small) keygap(1) ring(0) position(12) row(1))                           ///
		plotregion(lc(none)) xsize(1.75) ysize(1)
	*graph export "Data/Figures/FigC2_Excluding_each_PKO_case.pdf", as(pdf) replace

	/*Why DRC and Sudan?*/
	gen location2 = location if g == 3 | g == 9
	replace location2 = "DR Congo: Government" if g == 3
	replace location2 = "Sudan: Government"    if g == 9
	twoway ///
		scatter bd_govt_ged ym, msize(tiny) mc(black)               || ///
		line ln_srf_militaryexp ym, yaxis(2) lc(blue%50) lw(thick)  || ///
		line ln_srf_policeexp   ym, yaxis(2) lc(green%50) lw(thick) || ///
		line ln_srf_civilianexp ym, yaxis(2) lc(pink%50) lw(thick)     ///
		by(location2, row(2) note("")) title("") xtitle("")            ///
		ytitle("") l1title("# of BRDs") r1title("Expenditures", orientation(rvertical)) ///
		xlabel(360(60)660, grid format(%tmCCYY)) ylabel(0(1000)3050, grid angle(0) format(%12.0fc)) ylabel(0(50)150, axis(2) angle(0)) ///
		legend(order( 1 "Government BRDs" 2 "Military" 3 "Police" 4 "Civilian" ) row(1) size(small) region(lc(none))) ///
		plotregion(lc(none))
	*graph export "Data/Figures/FigC3_Cases_of_DRC_and_Sudan.pdf", as(pdf) replace




/*6. Sample selections in terms of peace/war month duration*/
	use "Data/Dataset_monthly.dta", clear
	global pkexps   = "l.ln_srf_civilianexp l.ln_srf_militaryexp l.ln_srf_policeexp"
	global controls = "pa bd_total_osv_govt_binary bd_total_osv_rebel_binary bd_total_nsv_binary ln_oda ln_milper ln_gdp ln_pop v2x_polyarchy l.spm ropko stpko"

	/*Sample selection with the duration of peace months
	  -> UCDP defines a war inflicts more than or equal to 25 battle-related deaths
		 in a calendar year. Because the time unit of data is a month, and the dependent
		 variable is # of deaths only inflicted by the rebel side, the threshold for a war
		 in this analysis should be set as [(25/12 months)/2 sides =] 1.04 deaths.*/
	*count                     /*56,908*/
	*count if bd_govt_ged == 0 /*48,999 = 86.10%*/
	*count if bd_govt_ged == 1 /* 1,040 =  1.83%*/

	by conflict_id: gen x = _n
	by conflict_id: gen govt_Below2T = 1 if ///
		(bd_govt_ged < 2 & bd_govt_ged[_n-1] >= 2 & bd_govt_ged[_n-1] != .) | ///
		(bd_govt_ged < 2 & x == 1)
	by conflict_id: replace govt_Below2T = govt_Below2T[_n-1] + 1 if ///
		bd_govt_ged < 2 & govt_Below2T[_n-1] != .
	*hist govt_Below2T, freq dis
	*scatter ym govt_Below2T
/*
	sort govt_Below2T conflict_id ym
	gen govt_Below2T_id = _n if govt_Below2T == 1
	sort conflict_id ym
	by conflict_id: replace govt_Below2T_id = govt_Below2T_id[_n-1] if govt_Below2T != . & govt_Below2T_id[_n-1] != .
	sort govt_Below2T_id ym
	by govt_Below2T_id: egen govt_Below2T_duration = max(govt_Below2T)
	gen ln_govt_Below2T_duration = ln(govt_Below2T_duration)
	*hist govt_Below2T_duration if govt_Below2T == 1, freq dis
*/
	capture drop t bciv pciv llciv ulciv
	sort conflict_id ym
	gen t     = .
	gen bciv  = .
	gen pciv  = .
	gen llciv = .
	gen ulciv = .

	local i = 1
	foreach num of numlist 360 /*359(1)25*/ 24(1)0 {
		xtreg bd_govt_ged $pkexps $controls i.ym c.time#i.conflict_id ///
			if govt_Below2T <= `num' | govt_Below2T == . |            ///
			!(l.ln_srf_militaryexp == 0 & l.ln_srf_policeexp == 0 & l.ln_srf_civilianexp == 0), ///
			fe cluster(conflict_id)

		matrix A = r(table)
		replace t     = `num'  in `i'
		replace bciv  = A[1,1] in `i'
		replace pciv  = A[4,1] in `i'
		replace llciv = A[5,1] in `i'
		replace ulciv = A[6,1] in `i'

		local i = `i' + 1
	}

	recode t (360=29)
	capture label drop t
	label define t 29 "original"
	label values t t
	twoway ///
		rbar llciv ulciv t if pciv <  0.05, barwidth(.2) lc(black%0) fc(black%50) || ///
		rbar llciv ulciv t if pciv >= 0.05, barwidth(.2) lc(red%0)   fc(red%50)   || ///
		connected  bciv  t, lc(black) mc(black) m(oh) msize(large) yline(0, lp(dash) lc(black)) ///
		title("") xtitle("{&gt} #th of consecutive peace months excluded") ///
		ytitle("Coefficient for {it:Civilian Expenditures}")               ///
		xlabel(0(6)24 29, valuelabel) ylabel(-2(1)0.3, grid angle(0)) xscale(reverse) ///
		legend(order(3 "point estimate" 1 "significant at 5%" 2 "not significant") region(lc(none) fc(none)) ///
		symxsize(2) symysize(2) size(small) keygap(1) ring(0) position(5) row(3))                            ///
		plotregion(lc(none)) xsize(1.75) ysize(1) text(0.2 15 "# of observations decreases {&rarr}", size(small))
	*graph export "Data/Figures/FigC4_Sample_selection_with_peace_months.pdf", as(pdf) replace


	/*Sample selection with the duration of war months*/
	by conflict_id: gen govt_Above1T = 1 if ///
		(bd_govt_ged > 1 & bd_govt_ged != . & bd_govt_ged[_n-1] < 2) | ///
		(bd_govt_ged > 1 & bd_govt_ged != . & x == 1)
	by conflict_id: replace govt_Above1T = govt_Above1T[_n-1] + 1 if ///
		bd_govt_ged > 1 & bd_govt_ged != . & govt_Above1T[_n-1] != .
	*sum govt_Above1T /*max = 187*/
	*hist govt_Above1T, freq dis
	*scatter ym govt_Above1T
/*
	sort govt_Above1T conflict_id ym
	gen govt_Above1T_id = _n if govt_Above1T == 1
	sort conflict_id ym
	by conflict_id: replace govt_Above1T_id = govt_Above1T_id[_n-1] if govt_Above1T != . & govt_Above1T_id[_n-1] != .
	sort govt_Above1T_id ym
	by govt_Above1T_id: egen govt_Above1T_duration = max(govt_Above1T)
	gen ln_govt_Above1T_duration = ln(govt_Above1T_duration)
	*hist govt_Above1T_duration if govt_Above1T == 1, freq dis
*/
	capture drop t bciv pciv llciv ulciv
	sort conflict_id ym
	gen t     = .
	gen bciv  = .
	gen pciv  = .
	gen llciv = .
	gen ulciv = .

	local i = 1
	foreach num of numlist 192 /*187(1)25*/ 24(1)0 {
		xtreg bd_govt_ged $pkexps $controls i.ym c.time#i.conflict_id ///
			if govt_Above1T <= `num' | govt_Above1T == . |            ///
			!(l.ln_srf_militaryexp == 0 & l.ln_srf_policeexp == 0 & l.ln_srf_civilianexp == 0), ///
			fe cluster(conflict_id)

		matrix A = r(table)
		replace t     = `num'  in `i'
		replace bciv  = A[1,1] in `i'
		replace pciv  = A[4,1] in `i'
		replace llciv = A[5,1] in `i'
		replace ulciv = A[6,1] in `i'

		local i = `i' + 1
	}

	recode t (192=29)
	capture label drop t
	label define t 29 "original"
	label values t t
	twoway ///
		rbar llciv ulciv t if pciv <  0.05, barwidth(.2) lc(black%0) fc(black%50) || ///
		rbar llciv ulciv t if pciv >= 0.05, barwidth(.2) lc(red%0)   fc(red%50)   || ///
		connected  bciv  t, lc(black) mc(black) m(oh) msize(large) yline(0, lp(dash) lc(black)) ///
		title("") xtitle("{&gt} #th of consecutive war months excluded") ///
		ytitle("Coefficient for {it:Civilian Expenditures}")             ///
		xlabel(0(6)24 29, valuelabel) ylabel(-2(1)0.3, grid angle(0)) xscale(reverse) ///
		legend(order(3 "point estimate" 1 "significant at 5%" 2 "not significant") region(lc(none) fc(none)) ///
		symxsize(2) symysize(2) size(small) keygap(1) ring(0) position(5) row(3))                            ///
		plotregion(lc(none)) xsize(1.75) ysize(1) text(0.2 15 "# of observations decreases {&rarr}", size(small))
	*graph export "Data/Figures/FigC5_Sample_selection_with_war_months.pdf", as(pdf) replace




/*7. Local ownership effect of UN civilian peacekeepers*/
	use "Data/02. Peacekeeping/UNPO6_financial_resources_base.dta", clear
	*graph bar (sum) CivnatExp CivintlExp IntlconExp ConsulExp UNVExp TemporaryExp GovtExp ElectionExp StaffassessExp, stack percentages over(Session)
	*graph bar (sum) CivnatExp CivintlExp, stack percentages over(Session) /*Ratio in the aggregation does not change much.*/
	gen CivnatPct = CivnatExp / CivilianExp
	graph box CivnatPct, over(Session)
	codebook CivnatPct if Session == 74 /*26.77% at the median, per mission (2018-2019)*/
	codebook CivnatPct if Session <= 52 /* 8.53% at the median, per mission (before 1996)*/

	use "Data/Dataset_monthly.dta", clear
	global pkexps_subciv = "l.ln_srf_civintlexp l.ln_srf_civnatexp l.ln_srf_unvexp l.ln_srf_militaryexp l.ln_srf_policeexp"
	global controls      = "pa bd_total_osv_govt_binary bd_total_osv_rebel_binary bd_total_nsv_binary ln_oda ln_milper ln_gdp ln_pop v2x_polyarchy l.spm ropko stpko"

	/*(1) DV = all BRDs*/
	xtreg bd_best_ged $pkexps_subciv $controls i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m1_subciv

	/*(2) DV = BRDs on the government side*/
	xtreg bd_govt_ged $pkexps_subciv $controls i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m2_subciv

	/*(3) DV = BRDs on the rebel side*/
	xtreg bd_rebel_ged $pkexps_subciv  $controls i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m3_subciv

	esttab m1_subciv m2_subciv m3_subciv, /*tex*/ ///
		nogap compress unstack noomitted drop(*.ym *.conflict_id#c.time _cons) b(3) se(3) ///
		stat(War_FEs YM_FEs War_FEsT N r2_w, label("War FEs" "Year-month FEs" "War FEs * t" "N" "R-squared (within)") ///
		fmt(%3s %3s %3s %9.0gc %12.3fc)) star(+ 0.10 * 0.05 ** 0.01 *** 0.001)            ///
		title("FE OLS using civilian subcategories")                                      ///
		/*numbers("Model C10-")*/ varwidth(53) modelwidth(10) mlabels("Total" "Government" "Rebel") ///
		coeflabels(L.ln_srf_civintlexp "International Civilian Expenditures\(_{t-1}\)" L.ln_srf_civnatexp "Local Civilian Expenditures\(_{t-1}\)" L.ln_srf_unvexp "UN Volunteers Expenditures\(_{t-1}\)" ///
				   L.ln_srf_militaryexp "Military Expenditures\(_{t-1}\)" L.ln_srf_policeexp "Police Expenditures\(_{t-1}\)" ///
				   pa "Peace Agreement" bd_total_osv_govt_binary "Government OSV"                 ///
				   bd_total_osv_rebel_binary "Rebel OSV" bd_total_nsv_binary "Non-State Violence" ///
				   ln_oda "log(ODA)" ln_milper "log(Army Size)" ln_gdp "log(GDP)" ln_pop "log(Population)" ///
				   v2x_polyarchy "Democracy" L.spm "SPM\(_{t-1}\)" ropko "Regional PKO" stpko "State PKO") ///
		note("Robust standard errors clustered at conflict in parentheses.")




/*8. Interaction effect of civilian and military components*/
	use "Data/Dataset_monthly.dta", clear
	*scatter ln_srf_civilianexp ln_srf_militaryexp if ln_srf_civilianexp != 0 & ln_srf_militaryexp != 0, mlab(location) xlabel(0(50)200) ylabel(0(50)200) xsize(1) ysize(1)
	/*Note: Sudan has huge values when civilian and military expenditures are interacted (cf. roubstness check 5).
	  e.g., BiH: 200*50 = 10000 while Sudan: 150*100 = 15000.*/

	global pkexps_int = "cl.ln_srf_civilianexp##cl.ln_srf_militaryexp l.ln_srf_policeexp"
	global controls   = "pa bd_total_osv_govt_binary bd_total_osv_rebel_binary bd_total_nsv_binary ln_oda ln_milper ln_gdp ln_pop v2x_polyarchy l.spm ropko stpko"

	/*(1) DV = all BRDs*/
	xtreg bd_best_ged $pkexps_int $controls i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m1_int

	/*(2) DV = BRDs on the government side*/
	xtreg bd_govt_ged $pkexps_int $controls i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m2_int

	/*(3) DV = BRDs on the rebel side*/
	xtreg bd_rebel_ged $pkexps_int $controls i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	estadd local War_FEs  "YES"
	estadd local YM_FEs   "YES"
	estadd local War_FEsT "YES"
	est sto m3_int

	esttab m1_int m2_int m3_int, /*tex*/ ///
		nogap compress unstack noomitted drop(*.ym *.conflict_id#c.time _cons) b(3) se(3) ///
		stat(War_FEs YM_FEs War_FEsT N r2_w, label("War FEs" "Year-month FEs" "War FEs * t" "N" "R-squared (within)") ///
		fmt(%3s %3s %3s %9.0gc %12.3fc)) star(+ 0.10 * 0.05 ** 0.01 *** 0.001)            ///
		title("FE OLS using an interaction term of civilian and military expenditures")   ///
		/*numbers("Model C11-")*/ varwidth(40) modelwidth(10) mlabels("Total" "Government" "Rebel") ///
		coeflabels(L.ln_srf_civilianexp "Civilian Expenditures\(_{t-1}\)" L.ln_srf_militaryexp "Military Expenditures\(_{t-1}\)" ///
				   cL.ln_srf_civilianexp#cL.ln_srf_militaryexp "Civilian\(_{t-1}\) * Military\(_{t-1}\)" L.ln_srf_policeexp "Police Expenditures\(_{t-1}\)" ///
				   pa "Peace Agreement" bd_total_osv_govt_binary "Government OSV"                 ///
				   bd_total_osv_rebel_binary "Rebel OSV" bd_total_nsv_binary "Non-State Violence" ///
				   ln_oda "log(ODA)" ln_milper "log(Army Size)" ln_gdp "log(GDP)" ln_pop "log(Population)" ///
				   v2x_polyarchy "Democracy" L.spm "SPM\(_{t-1}\)" ropko "Regional PKO" stpko "State PKO") ///
		note("Robust standard errors clustered at conflict in parentheses.")

	xtreg bd_govt_ged $pkexps_int $controls i.ym c.time#i.conflict_id, fe cluster(conflict_id)
	*lincom L.ln_srf_militaryexp + cL.ln_srf_civilianexp#cL.ln_srf_militaryexp
	*margins, dydx(L.ln_srf_militaryexp) at(L.ln_srf_civilianexp = (0(10)120)) saving("Data/Marginal_effect_of_military_interaction.dta",  replace)
	*margins, dydx(L.ln_srf_civilianexp) at(L.ln_srf_militaryexp = (0(10)120)) saving("Data/Marginal_effect_of_civilian_interaction.dta",  replace)
	use "Data/Marginal_effect_of_military_interaction.dta", clear
	append using "Data/Marginal_effect_of_civilian_interaction.dta"
	twoway ///
		rarea _ci_ub _ci_lb _at1 in 1/13,  lc(blue%0) fc(blue%50) || ///
		line _margin        _at1 in 1/13,  lc(black)  lp(dash)    || ///
		rarea _ci_ub _ci_lb _at2 in 13/26, lc(pink%0) fc(pink%50) || ///
		line _margin        _at2 in 13/26, lc(black)  lp(dash)       ///
		xlabel(0(30)120, grid) ylabel(-4(2)4, grid gmax angle(0))    ///
		xtitle("Size of expenditures on condition") ytitle("Effect of expenditures") ///
		legend(order(1 "Military expenditures" 3 "Civilian expenditures") ///
		row(2) ring(0) position(11) region(lc(none) fc(none))) plotregion(lc(none))
	*graph export "Data/Figures/FigC6_Effect_of_interaction_term.pdf", as(pdf) replace




